package com.gensdai.leliang.dialog;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.TextView;

import com.flyco.roundview.RoundTextView;
import com.gensdai.leliang.AppApplication;
import com.gensdai.leliang.R;
import com.gensdai.leliang.popupwindow.BasePopupWindow;

/**
 * Created by Administrator on 2017/6/7.
 */

public class dialog_select_pay_type extends BasePopupWindow {


    private View popupView;
    private RoundTextView paybtn;
    private TextView pricelable;
    ImageView closeBtn;                    //关闭按钮

    OnPayDoneClick click;
    private String priceText = "0";

    public void setPrice(String priceText) {
        this.priceText = priceText;
        if (pricelable != null) {
            pricelable.setText(AppApplication.getContext().getString(R.string.rmb2) + priceText);
        }
    }

    public void setOnPayClick(OnPayDoneClick click) {
        this.click = click;
    }

    public dialog_select_pay_type(Activity context) {
        super(context);
        bindview();
    }

    private void bindview() {
        pricelable = (TextView) popupView.findViewById(R.id.priceLable);
        paybtn = (RoundTextView) popupView.findViewById(R.id.paybtn);
        closeBtn = (ImageView) popupView.findViewById(R.id.closeBtn);

        paybtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (click != null) {
                    click.onPayClick();
                }
            }
        });

        closeBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @Override
    public View onCreatePopupView() {
        popupView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_select_pay_type, null);
        return popupView;
    }

    @Override
    public View initAnimaView() {
        return popupView.findViewById(R.id.chidView);
    }

    @Override
    protected Animation initShowAnimation() {
        return getTranslateAnimation(250 * 5, 0, 260);
    }
    @Override
    protected Animation initExitAnimation() {
        return getTranslateAnimation(0, 250 * 5, 260);
    }

    @Override
    public View getClickToDismissView() {
        return getPopupWindowView();
    }


    /*interface*/

    public interface OnPayDoneClick {
        void onPayClick();
    }
}
